// This class defines functions to play streaming and how to stop it.
// Hopefully, this is true today. If you find some bugs, feel free to
// repair those things.
// T
// This first section is for example only

function create(swfobject) {
	// creates player based on nothing. sample only.
	var o = swfobject.getObjectById("object");
	if(o) { o.removeSWF("object"); }
    currentPlayId = 0;
    var flashvars = {
        streamer:"rtmp://stm.melon.co.id/prelisten",
        file:"melon",
        autostart:"true",
        icons:false
    }
    var params = {
        allowfullscreen:"true",
        allowscriptaccess:"always"
    }
    var attributes = {
        id:"object",
        name:"object"
    }
    swfobject.embedSWF(
    		"http://melon.co.id/flash/player.swf?songId=110100719&contentType=M&channelCd=CH0023", 
    		"container", "0", "0", "9.0.115", false, flashvars, params, attributes);
}

function stop(swfbject) {
	// stop the streaming from playing.
	if(swfobject) {
		console.log("swfobject this instance found.");
	}
	var o = swfobject.getObjectById("object");
	if(o) {
		console.log("object at id 'object' found");
		swfobject.removeSWF("object");
	}
}

// This second section is for defining create() and stop() for real

function create(swfobject	, certificate) {
	var o = swfobject.getObjectById("object");
	if(o) { o.removeSWF("object"); }
    currentPlayId = 0;
    var flashvars = {
        streamer:"rtmp://stm.melon.co.id/prelisten",
        file:"melon",
        autostart:"true",
        icons:false
    }
    var params = {
        allowfullscreen:"true",
        allowscriptaccess:"always"
    }
    var attributes = {
        id:"object",
        name:"object"
    }
    if(certificate) {
        swfobject.embedSWF(
        		"http://melon.co.id/flash/player.swf?certificate="+ certificate +"&contentType=M&channelCd=CH0023", 
        		"container", "0", "0", "9.0.115", false, flashvars, params, attributes);    	
    }
}

function stop(swfobject) {
	
}